package net.chromedpork.hypertext.sanitization;



import java.io.IOException;

import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;



/**
 *
 *  Tag cleaning object.
 * 
 *  @author Inode <inode@chromedpork.net>
 *
 */

public class Cleaner
{
    /**
     *
     *  Cleans up HTML into something resembling well-formed XML.
     * 
     *  @param html     string containing HTML tag tree
     *
     *  @return TagNode representing the clean XML tag tree
     *
     *  @throws CleanerException
     *
     */

    public static TagNode cleanHTML(String html) throws CleanerException
    {
        try
        {
            return ((new HtmlCleaner()).clean(html));
        }

        catch (IOException exception)
        {
            throw new CleanerException(exception.getMessage());
        }
    }
}
